package com.cecsmsserve.mapper;

import com.cecsmsserve.entity.ServiceOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Param;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 王郝浠
 * @since 2024-04-17
 */
public interface ServiceOrderMapper extends BaseMapper<ServiceOrder> {

    @ResultMap("serviceOrderMap")
    @Select("select * from service_order where uId=#{uId} order by orderDate DESC,orderTime DESC")
    List<ServiceOrder> selectByUId(@Param("uId") int uId);

    @ResultMap("serviceOrderMap")
    @Select("select * from service_order where uId=#{arg0} and orderState=#{arg1}")
    List<ServiceOrder> selectByuIdByState(@Param("uId") int uId, @Param("state") int state);

    @Select("select * from service_order where orderState=#{orderState}")
    List<ServiceOrder> selectByState(@Param("orderState") int orderState);

    @ResultMap("serviceOrderMap")
    @Select("select * from service_order order by id desc limit #{arg0},#{arg1}")
    List<ServiceOrder> selectAllByPage(@Param("start") int start, @Param("size") int size);

    @ResultMap("serviceOrderMap")
    @Select("select * from service_order where typeBId!=4 order by id desc limit #{arg0},#{arg1}")
    List<ServiceOrder> selectServiceByPage(@Param("start") int start, @Param("size") int size);

    @ResultMap("serviceOrderMap")
    @Select("select * from service_order where typeBId=4 order by id desc limit #{arg0},#{arg1}")
    List<ServiceOrder> selectHealthByPage(@Param("start") int start, @Param("size") int size);

    List<HashMap<String, Object>> countRate();
}
